<include file="Public:_head" />
<include file="Public:left" />
	<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
	<div id="neirong">
    
 		<!--<h2 class="lm_title">分店管理</h2>-->
   
    
                <div id="FenDian">
                    <div id="addFenDian">
                        <h3>修改门店</h3>
                        <form action="{:U('Setting/doedit_store',array('sid'=>$store['sid']))}" class="form" method="post">
						<p>门店名称：<input name="store_name" value="{$store.store_name}" type="text" class="text" /></p>
                        <p>门店地址：
							<select name="pro" class="s-text-select pro">
								<option value="0" selected>省</option>
								<volist name="pro" id="p">
								<option  value="{$p.area_id}" <if condition="$p.area_id eq $store['pro']">selected</if>>{$p.title}</option>
								</volist>
							</select>
							<select name="city" class="s-text-select city">
								<option value="{$store.city}" selected>{$store.city|getareaname}</option>
							</select>
							<select name="area" class="s-text-select area">
								<option value="{$store.area}" selected>{$store.area|getareaname}</option>
							</select>
							<input name="address" value="{$store.address}" type="text" class="text add200" />
							<input type="hidden" name="map_x" id="map_x" value="{$store.map_x}" />
							<input type="hidden" name="map_y" id="map_y" value="{$store.map_y}" />
                            <a href="javascript:" class="dingwei">定位</a>
                        </p>
                        <div class="map">
							<div style="width:603px;height:300px" id="map"></div>
                        </div>
                         <button class="btn_send"  type="submit">修改</button>
                        </form>
                    </div>
                    <!-- addFenDian结束 -->
            
                </div>
                <!-- FenDian结束 -->
	</div>
	<!-- neirong结束 -->
	<span class="clear"></span>
	<!-- 清除浮动 -->
</div>
<!-- container结束 -->
<script>
	$(document).ready(function(){
		$(".pro").change(function(){
			pro = $(this).val();
			$.post('__URL__/getarea',{type:'city',aid:pro},function(res){
				$(".city option").remove();
				$(".city").append("<option value='0'>市</option>");
				for(i=0;i<res.length;i++){
					$(".city").append("<option value='"+res[i]['area_id']+"'>"+res[i]['title']+"</option>");
				}
				//alert(res);
			},'json');
		});
		$(".city").change(function(){
			city = $(this).val();
			$.post('__URL__/getarea',{type:'area',aid:city},function(res){
				$(".area option").remove();
				$(".area").append("<option value='0'>区</option>");
				for(i=0;i<res.length;i++){
					$(".area").append("<option value='"+res[i]['area_id']+"'>"+res[i]['title']+"</option>");
				}
				//alert(res);
			},'json');
		});
		var center = new qq.maps.LatLng({$store.map_x},{$store.map_y});
		var map = new qq.maps.Map(document.getElementById("map"),{
			center: center,
			zoom: 13
		});
		var marker = new qq.maps.Marker({
			position: center,
			map: map
		});
		qq.maps.event.addListener(map, 'click', function(event) {
			$("#map_x").val(event.latLng.getLat());
			$("#map_y").val(event.latLng.getLng());
			marker.setPosition(new qq.maps.LatLng(event.latLng.getLat(),event.latLng.getLng()));
		});
		geocoder = new qq.maps.Geocoder({
			complete : function(result){
				$("#map_x").val(result.detail.location.getLat());
				$("#map_y").val(result.detail.location.getLng());
				map.setCenter(result.detail.location);
				marker.setPosition(result.detail.location);
			}
		});
		$(".dingwei").click(function(){
			pro = $('.pro').find('option:selected').text();
			city = $('.city').find('option:selected').text();
			area = $('.area').find('option:selected').text();
			address = $('.add200').val();
			geocoder.getLocation(pro+city+area+address);			
		});
	});

</script>
<include file="Public:bottom" />
